草庐IT

php - 未找到 Selenium 元素

全部标签

javascript - Selenium 网络驱动程序 : execute_script can't execute custom methods and external javascript files

我正在使用Selenium和Python,我正在尝试做两件事:导入外部javascript文件并执行其中定义的方法在字符串上定义方法并在求值后调用它们这是第一种情况的输出:测试.jsfunctionhello(){document.body.innerHTML="testing";}Python代码>>>fromseleniumimportwebdriver>>>f=webdriver.Firefox()>>>f.execute_script("vars=document.createElement('script');\...s.src='file://C:/test.js';\..

javascript - 无法将 .focus() 赋予下拉菜单的元素

这是一个Boostrap导航栏,包含一个dropdown菜单,包含一个.当我点击下拉菜单时,它显示成功。的值成功改成Bonjour但是这个没有得到焦点。为什么?http://jsfiddle.net/rzsmdg4f/1/如何使用.focus()将焦点放在下拉菜单中包含的输入上?代码:DropdownLink:JS:{varmaa=document.getElementById('maa');console.log(maa);maa.addEventListener('click',function(){console.log($('#ha'));$('#ha').val('Bonjo

javascript - 如何使用 Selenium webdriver 测试对 SVG 对象的点击?

我正在尝试编写代码来检查单击SVG对象的功能-例如此URL上的美国州http://www.amcharts.com/svg-maps/?map=usa这行得通,但是有更好的方法吗?没有物理移动鼠标的东西?robert=newRobot();robert.mouseMove(x,y);//fullclickoncetogetfocusonthewindowrobert.mousePress(MouseEvent.BUTTON1_MASK);robert.mouseRelease(MouseEvent.BUTTON1_MASK);//thensetthefilterrobert.mouse

javascript - 使用 Protractor 访问 JS 作用域元素/变量

我有一个Protractor测试,它输入登录数据并单击登录按钮,我想检查Angular变量的值。点击元素的ng-click是doLogin(),它在Controller文件中定义为:$scope.doLogin=function(){console.log('login--todo');//rememberemailusedlocalStorageService.add('lastKeyEmail',$scope.data.login.key.email);//todo-makedynamic$scope.authentication.user=true;//setemailoflog

javascript - 是否有一种纯 Javascript 方法可以将一个函数应用于多个元素的事件?

我想使用纯Javascript将单个函数绑定(bind)到多个事件。在jQuery中我会使用:$('.className').click(function(e){//dostuff});所以我尝试使用纯JS:document.getElementsByClassName('className').onclick=function(e){//dostuff};这不起作用,因为getElementsByClassName返回一个数组,而不是DOM对象。我可以遍历数组,但这似乎过于冗长而且似乎没有必要:vartopBars=document.getElementsByClassName('c

javascript - 检查 jQuery 是否单击了包含 img 的 anchor 元素

如何检查点击的元素是否是包含img的anchor?例如,我想检查这个元素是否被点击:jQuery(document).click(function(e){//e.target.hereIsWhereINeedHelp;});提前致谢! 最佳答案 如果你想捕捉任何元素的“点击”:jQuery(document).click(function(e){if(jQuery(e.target).is('a')&&jQuery(e.target).has('img')){//codegoeshere}});您是否选择阻止“默认行为”是另一个问题

javascript - 如果 Angular 正在做......从 Selenium 中检测东西

为什么driver.findElement(statictext).getText()曾经返回“”吗?我有一个Angular应用程序,我正在osx上通过java通过chromedriver使用selenium进行测试。我有一些标记如下:statictext我经常得到:assert(driver.findElement(By.id("my-unique-id").getText().contains("statictext");产量:java.lang.AssertionError:Nottruethatcontains喜欢,30%的时间。我不明白该元素的.getText()如何计算为“

javascript - 根据其他所有元素对 Javascript 数组进行排序

假设我有一个这样的数组:vara=[94,"Neptunium",2,"Helium",null,"Hypotheticalium",64,"Promethium"];偶数数组索引与以下奇数索引链接。换句话说,94与“Neputunium”一起使用,2与“Helium”一起使用等。如何根据偶数索引对数组进行排序,但在其后保留以下奇数索引值?这样我就得到了一个像这样的数组:a=[null,"Hypotheticalium",2,"Helium",64,"Promethium",94,"Neptunium"];注意:是的,我确实知道使用对象或ES6Map(或者,在这种情况下,如果null被

javascript - Angular2 ElementRef nativeElement 检查元素是否被禁用

我的指令中有这个,名为“bgcolor”:exportclassBgColorDirective{constructor(el:ElementRef){console.log(el.nativeElement.disabled);//show"false"if(el.nativeElement.disabled){el.nativeElement.style.backgroundColor='#5789D8';el.nativeElement.style.color='#FFFFFF';}}在我的模板中,我有:我不明白为什么el.nativeElement.disabled返回fals

javascript - 清除不再引用且从未添加到文档中的元素

假设我创建了一个新元素:letcanvas=document.createElement('canvas');现在,稍后在脚本中,我删除了对它的所有JS引用。canvas=null;Canvas元素本身是否还存在,占用内存?或者它会像任何其他未引用的对象一样被垃圾收集吗?请注意,我实际上并没有将它添加到文档中。 最佳答案 Doestheelementitselfstillexist,takingmemory?Orwillitbegarbagecollectedlikeanyotherunreferencedobject?是的,暂时还